<template>
	<view class="container">
		<view class="header">
			<view class="item">
				<text>{{teamNum}}</text>
				<text>推广人数</text>
			</view>
		</view>
		<view class="cut"></view>
		<view class="member">
			<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltolower="lower">
				<view class="top"></view>
				<view class="item" v-for="(item,index) in teamList" :key="index">
					<view class="left">
						<image :src="item.avatar" mode="aspectFill"></image>
						<view>
							<text class="clamp">{{item.nickname}}</text>
							<text>{{item.phone}}</text>
						</view>
					</view>
					<view class="right">
						<text class="b">{{item.spread_seller_time}}</text>
					</view>
				</view>
				<uni-load-more class="loadMore" iconType="circle" :status="loadStatus" :contentText="contentText"></uni-load-more>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {
		sellerPromoterList
	} from '@/api/merchant.js'
	import utils from '@/utils/util.js'
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue";
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				scrollTop: 0,
				teamList: [],
				loadStatus: "loading",
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多了"
				},
				page: 1,
				limit: 15,
				teamNum: 0,
			};
		},
		onLoad() {
			this.getData()
		},
		methods: {
			lower() {
				if (this.loadStatus == "more")
					(this.loadStatus = "loading"), this.getData();
			},
			getData() {
				sellerPromoterList({
					page: this.page,
					limit: this.limit
				}).then(res => {
					this.teamNum = res.data.count
					this.loadStatus = "more"
					this.teamList.push.apply(this.teamList, res.data.seller_team_list);
					if (res.data.seller_team_list.length < this.limit) this.loadStatus = "noMore";
					this.page = this.page + 1;
					if (this.teamList.length == 0) {
						this.contentText.contentnomore = '暂无数据'
					}
				})
			}
		}
	};
</script>

<style lang="scss" scoped>
	.container {
		.header {
			display: flex;
			justify-content: space-around;
			height: 180rpx;
			color: #fff;
			background-color: $theme-color;

			.item {
				display: flex;
				flex-direction: column;
				justify-content: center;
				text-align: center;

				text:nth-of-type(1) {
					font-size: 46rpx;
					font-weight: bold;
					color: rgba(255, 255, 255, 1);
				}

				text:nth-of-type(2) {
					margin-top: 10rpx;
					font-size: 24rpx;
					font-weight: 400;
					color: rgba(255, 255, 255, 1);
				}
			}
		}

		.cut {
			background-color: $theme-color;
			height: 50rpx;
		}

		.member {
			height: calc(100vh - 190rpx);
			padding: 0 60rpx;
			box-sizing: border-box;
			background-color: #fff;
			border-radius: 40rpx 40rpx 0px 0px;
			margin-top: -40rpx;

			.scroll-Y {
				height: 100%;

				.top {
					height: 40rpx;
				}
			}

			.item {
				display: flex;
				justify-content: space-between;
				height: 160rpx;
				border-bottom: 1rpx solid #eee;

				.left {
					display: flex;
					align-items: center;

					image {
						margin-right: 30rpx;
						width: 100rpx;
						height: 100rpx;
						border-radius: 50rpx;
						background-color: $theme-color;
					}

					view {
						display: flex;
						flex-direction: column;
						justify-content: space-between;
						width: 200rpx;

						text:nth-of-type(1) {
							font-weight: bold;
							font-size: 28rpx;
							color: rgba(51, 51, 51, 1);
						}

						text:nth-of-type(2) {
							margin-top: 10rpx;
							font-size: 22rpx;
							font-weight: 400;
							color: rgba(153, 153, 153, 1);
						}
					}
				}

				.right {
					display: flex;
					align-items: center;

					.a {
						font-size: 24rpx;
						color: #999;
					}

					.b {
						font-size: 24rpx;
						color: #999;
					}
				}
			}
		}
	}
</style>
